precision mediump float;
uniform vec4 u_fogColor;
uniform float u_fogMaxDist;
uniform float u_fogMinDist;
uniform sampler2D baseMap;
varying vec2 v_texCoord;
varying float v_eyeDist;
float computeLinearFogFactor()
{
	   float factor;
	   factor = (u_fogMaxDist - v_eyeDist)/(u_fogMaxDist - u_fogMinDist);
	    factor = clamp(factor, 0.0, 1.0);
	    return factor;            
	   
}
void main(void)
{
	    float fogFactor = computeLinearFogFactor();
		vec4  fogColor  = fogFactor * u_fogColor;	    
		vec4 baseColor = texture2D( baseMap, v_texCoord );
		gl_FragColor = baseColor * fogFactor + fogColor  * (1.0 - fogFactor);
}